package cn.edu.cqut.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import cn.edu.cqut.entity.DivideModel;
import cn.edu.cqut.entity.Orders;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author cqut-917371
 * @since 2020-06-24
 */
public interface OrdersMapper extends BaseMapper<Orders> {
	// 根据年份查找订单信息
	@Select("select * from orders where DATE_FORMAT(or_date,'%Y') like '%${date}%'")
	public Page<Orders> selectOrderCountByDate(Page<Orders>page, @Param("date") String date);
	
	@Select("select DATE_FORMAT(or_date,'%Y-%m-%d') name, or_totalprice value from orders WHERE cus_name = '${name}'")
	public List<DivideModel> selectOrderByCus_Name(@Param("name") String name);
	
	@Select("select DATE_FORMAT(or_date,'%Y-%m') name, SUM(or_totalprice) value FROM orders WHERE DATE_FORMAT(or_date,'%Y') = ${date}  GROUP BY DATE_FORMAT(or_date,'%Y-%m')")
	public List<DivideModel> selectOrderByDate(@Param("date") String date);
}
